import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
const home=()=>import( '@/views/home/home.vue')
const cart=()=>import('@/views/cart/cart.vue')
const user=()=>import('@/views/user.vue')
const detail=()=>import('@/views/detail/detail.vue')



const routes = [
  {
    path:'/',
    redirect:'/home'
    
  }
  ,
  {
    path: '/home',
    name: 'home',
    component: home,
    meta:'首页'
  },
   {
    path: '/cart',
    name: 'cart',
    meta:'购物车',
    component: cart
   },
   {
    path: '/user',
    name: 'user',
    meta:'用户',
    component: user
   },
   {
    path: '/detail/:iid',
    name: 'detail',
    meta:'详情',
    component: detail
   },
]

const router = createRouter({
  history: createWebHashHistory(),
  
  routes
})

router.beforeEach((to,from,next)=>{
  document.title=to.matched[0].meta
  next()
})



export default router
